﻿<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="util.JdbcUtil" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="bean.AdminBean" %>
<%@ page import="java.util.ArrayList" %>
<!DOCTYPE html>
<html>
  <head>
    <title>administrator</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <link href="resources/css/axure_rp_page.css" type="text/css" rel="stylesheet"/>
    <link href="data/styles.css" type="text/css" rel="stylesheet"/>
    <link href="files/administrator/styles.css" type="text/css" rel="stylesheet"/>
    <link rel="stylesheet" type="text/css" href="layui/css/laytable.css">
    <script src="resources/scripts/jquery-3.2.1.min.js"></script>
    <script src="resources/scripts/axure/axQuery.js"></script>
    <script src="resources/scripts/axure/globals.js"></script>
    <script src="resources/scripts/axutils.js"></script>
    <script src="resources/scripts/axure/annotation.js"></script>
    <script src="resources/scripts/axure/axQuery.std.js"></script>
    <script src="resources/scripts/axure/doc.js"></script>
    <script src="resources/scripts/messagecenter.js"></script>
    <script src="resources/scripts/axure/events.js"></script>
    <script src="resources/scripts/axure/recording.js"></script>
    <script src="resources/scripts/axure/action.js"></script>
    <script src="resources/scripts/axure/expr.js"></script>
    <script src="resources/scripts/axure/geometry.js"></script>
    <script src="resources/scripts/axure/flyout.js"></script>
    <script src="resources/scripts/axure/model.js"></script>
    <script src="resources/scripts/axure/repeater.js"></script>
    <script src="resources/scripts/axure/sto.js"></script>
    <script src="resources/scripts/axure/utils.temp.js"></script>
    <script src="resources/scripts/axure/variables.js"></script>
    <script src="resources/scripts/axure/drag.js"></script>
    <script src="resources/scripts/axure/move.js"></script>
    <script src="resources/scripts/axure/visibility.js"></script>
    <script src="resources/scripts/axure/style.js"></script>
    <script src="resources/scripts/axure/adaptive.js"></script>
    <script src="resources/scripts/axure/tree.js"></script>
    <script src="resources/scripts/axure/init.temp.js"></script>
    <script src="resources/scripts/axure/legacy.js"></script>
    <script src="resources/scripts/axure/viewer.js"></script>
    <script src="resources/scripts/axure/math.js"></script>
    <script src="resources/scripts/axure/jquery.nicescroll.min.js"></script>
    <script src="data/document.js"></script>
    <script src="files/administrator/data.js"></script>
    <script type="text/javascript">
      $axure.utils.getTransparentGifPath = function() { return 'resources/images/transparent.gif'; };
      $axure.utils.getOtherPath = function() { return 'resources/Other.html'; };
      $axure.utils.getReloadPath = function() { return 'resources/reload.html'; };
    </script>
    <script src="${pageContext.request.contextPath }/js/jquery.js"></script>
    <script >
      function add(aid){
        location.href="adminadd.jsp";
      }

      function modify(aid){
        var falg= confirm("确认修改吗？？？");
        if(falg){
          location.href="adminmodify?aid="+aid;
        }
      }
      function del(aid){
        var falg= confirm("确认删除吗？？？");
        if(falg){
          location.href="admindelete?aid="+aid;
        }
      }
      function hunt(){
        var aid = $("#aid").val();
        var name = $("#name").val();
        if (aid==null &&name==null){
          location.href="administrator.jsp";
        }
        $.ajax({
          url : "adminhunt?aid="+aid+"&name="+name,//提交地址
          type : "post",//提交方式（get,post）
          dataType : "json",//指定服务器返回的数据类型
          success : function(data) {//请求成功后的回调函数
            console.log(data);
            $("#tbody").empty(); //删除匹配的元素集合中所有的子节点（就是不重复执行）
            var trStr = "";
            for (var i = 0; i < data.length; i++) {
              trStr += "<tr><td>" + data[i].aid +
                      "</td><td>" + data[i].name +
                      "</td><td>" + data[i].sex +
                      "</td><td>" + data[i].age +
                      "</td><td>" + data[i].tel +
                      "</td><td>" + data[i].address +
                      "</td><td>" + data[i].wid +
                      "</td><td>" + " <input type='button' value='删除' onclick='del(${ad.aid})' />"
                      +"<input type='button' value='修改' onclick='modify(${ad.aid})' />"+
                      "</td></tr>"
            }
            $("#tbody").show().append(trStr);//向<tbody>内部追加内容
          },
          error : function() {
            alert('请求失败');
          }
        });
      }
    </script>
    <%
      String sql ="SELECT * FROM admin";
      try {
        PreparedStatement ps = JdbcUtil.getConnection().prepareStatement(sql);
        ResultSet set = ps.executeQuery();
        ArrayList<AdminBean> arr = new ArrayList<AdminBean>();
        while (set.next()){
          AdminBean ad = new AdminBean();
          ad.setAid(set.getInt(1));
          ad.setName(set.getString(2));
          ad.setSex(set.getString(3));
          ad.setAge(set.getInt(4));
          ad.setTel(set.getString(5));
          ad.setAddress(set.getString(6));
          ad.setWid(set.getInt(7));
          arr.add(ad);
        }
        System.out.println(arr.toString());
        session.setAttribute("arr", arr);
      } catch (Exception e) {
        e.printStackTrace();
      }
    %>
    <style>
      .dadbox{
        position: relative;
      }
      .addbtn{
        position: absolute;
        top: 80px;
        left: 50px;
      }
      .table_huowu{
        position: absolute;
        top: 120px;
        left: 50px;
      }
      .table_huowu table{
        border-collapse:collapse;
        width: 800px;
      }
      #u206_div{
        display: flex;
        justify-content: space-evenly;
        align-items: center;
        padding-top: 40px;
      }
      #aid,#name{
        width:200px;
        height: 30px;
      }
      #sub{
        text-align: center;
        width: 70px;
        height: 30px;
        background-color:rgb(130,212,248) ;
        border: 0 solid #ffffff;
      }
      #sut{
        background-color:rgb(130,212,248) ;
        width: 80px;
        height: 30px;
        text-align: center;
        color: #ffffff;
        border: 0 solid #ffffff;
        border-radius:3px;
      }
      td{
        white-space: nowrap;
      }
    </style>
  </head>
  <body>
    <div id="base" class="">

      <!-- Unnamed (矩形) -->
      <div id="u205" class="ax_default box_1">
        <div id="u205_div" class="dadbox">
          <%--按钮--%>
          <div class="addbtn">
            <input type="submit" value="添加" id="sut" onclick="add(${wa.wid})" />
          </div>
          <%--表格--%>
          <div class="table_huowu">
            <table  class="layui-table">
              <thead>
                <tr>
                  <th>仓库管理ID</th>
                  <th>员名</th>
                  <th>性别</th>
                  <th>年龄</th>
                  <th>电话</th>
                  <th>地址</th>
                  <th>所属仓库ID</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody id="tbody">
              <c:forEach items="${arr}" var="ad">
                <tr>
                  <td>${ad.aid}</td>
                  <td>${ad.name}</td>
                  <td>${ad.sex}</td>
                  <td>${ad.age}</td>
                  <td>${ad.tel}</td>
                  <td>${ad.address}</td>
                  <td>${ad.wid}</td>
                  <td>
                    <input type='button' value='删除' onclick='del(${ad.aid})' />
                    <input type='button' value='修改' onclick='modify(${ad.aid})' />
                  </td>
                </tr>
              </c:forEach>
              </tbody>
            </table>
          </div>

        </div>
        <div id="u205_text" class="text " style="display:none; visibility: hidden">
          <p></p>
        </div>
      </div>

      <!-- Unnamed (矩形) -->
      <div id="u206" class="ax_default box_1">
        <div id="u206_div" class="">
          <input id="aid" placeholder="管理员ID" type="text"/>
          <input type="text" id="name" placeholder="管理员名称"/>
          <input type="submit"id="sub" value="筛选" onclick="hunt()">
        </div>
        <div id="u206_text" class="text " style="display:none; visibility: hidden">
          <p></p>
        </div>
      </div>

      <!-- Unnamed (矩形) -->
      <div id="u210" class="ax_default box_1">
        <div id="u210_div" class=""></div>
        <div id="u210_text" class="text " style="display:none; visibility: hidden">
          <p></p>
        </div>
      </div>

      <!-- Unnamed (图片 ) -->
      <div id="u211" class="ax_default _图片_">
        <img id="u211_img" class="img " src="images/customer/u149.png"/>
        <div id="u211_text" class="text " style="display:none; visibility: hidden">
          <p></p>
        </div>
      </div>

      <!-- Unnamed (矩形) -->
      <div id="u212" class="ax_default label">
        <div id="u212_div" class=""></div>
        <div id="u212_text" class="text ">
          <p><span>筛选</span></p>
        </div>
      </div>

      <!-- Unnamed (矩形) -->
      <div id="u213" class="ax_default box_1">
        <div id="u213_div" class=""></div>
        <div id="u213_text" class="text " style="display:none; visibility: hidden">
          <p></p>
        </div>
      </div>

      <!-- Unnamed (SVG) -->
      <div id="u214" class="ax_default _图片_">
        <img id="u214_img" class="img " src="images/customer/u152.svg"/>
        <div id="u214_text" class="text " style="display:none; visibility: hidden">
          <p></p>
        </div>
      </div>

      <!-- Unnamed (矩形) -->
      <div id="u215" class="ax_default label">
        <div id="u215_div" class=""></div>
        <div id="u215_text" class="text ">
          <p><span>列表</span></p>
        </div>
      </div>

      <!-- Unnamed (矩形) -->
      <div id="u220" class="ax_default _文本段落">
        <div id="u220_div" class=""></div>
        <div id="u220_text" class="text ">
          <p><span>仓库管理员信息管理</span></p>
        </div>
      </div>

      <!-- 添加 (动态面板) -->
      <div id="u221" class="ax_default ax_default_hidden" data-label="添加" style="display:none; visibility: hidden">
        <div id="u221_state0" class="panel_state" data-label="State1" style="">
          <div id="u221_state0_content" class="panel_state_content">

            <!-- Unnamed (矩形) -->
            <div id="u222" class="ax_default box_1">
              <div id="u222_div" class=""></div>
              <div id="u222_text" class="text " style="display:none; visibility: hidden">
                <p></p>
              </div>
            </div>

            <!-- Unnamed (矩形) -->
            <div id="u223" class="ax_default _文本段落">
              <div id="u223_div" class=""></div>
              <div id="u223_text" class="text ">
                <p><span>仓库管理员ID</span></p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <script src="resources/scripts/axure/ios.js"></script>
  </body>
</html>
